/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package HelperClasses;

import java.awt.Dimension;
import java.awt.Point;

/**
 *
 * @author johannes
 */
public class GlobalFunctions {

    public static Dimension getScaledDimension(int oldWidth, int oldHeight,
            int newWidth, int newHeight) {
        double scaling = Math.min((double)newWidth / (double)oldWidth, (double)newHeight / (double)oldHeight);
        return new Dimension((int)((double)oldWidth * scaling), (int)((double)oldHeight * scaling));
    }
    
    public static double pointDistance(Point p1, Point p2) {
        double xdist = Math.abs(p1.getX() - p2.getX());
        double ydist = Math.abs(p1.getY() - p2.getY());
        // Pythagoras
        return Math.sqrt(Math.pow(xdist, 2) + Math.pow(ydist, 2));
    }
}
